package quickmall

class LoginController {

	def login = {
		if(params.email == "admin" && params.password == "admin" ){
			session.user = new User(email:"admin", password:"admin", name:"admin", store: new Store())
			redirect(controller:'mainPage',action:'index')
			return
		}
		
		def user = User.findWhere(email:params.email, password:params.password)
		session.user = user
		if (user)
			redirect(controller:'mainPage',action:'index')
		else
			redirect(controller:'login')
	}

	def logout = {
		session.user = null
		redirect (action: 'index')
	}

	def index() {
	}
}
